package ejercicio1;

/**
 *
 * @author diego
 */
public class UtilidadesString {

    public static int longitud (String cadena) {
        return cadena.trim().length();
    }
    
    public static int contar (String cadena, char c) {
        int i, j=0;
    
        for (i=0; i<cadena.length(); i++) 
            if (cadena.charAt(i) == c)
                j++;
        
        return j;
    }
    
    public static int contarVocales (String cadena) {
        int i, j, k=0;
        
        char vocales [] = {'a', 'e', 'i', 'o', 'u'};
        cadena = cadena.toLowerCase();
        
        for (i=0; i<cadena.length(); i++) 
            for (j=0; j<vocales.length; j++)
                if (cadena.charAt(i) == vocales[j])
                    k++;
        
        return k;
    }
}